package com.haier.dreambox.demo.net;

import com.haier.dreambox.demo.bean.*;
import org.androidannotations.annotations.rest.*;
import org.androidannotations.api.rest.MediaType;
import org.androidannotations.api.rest.RestClientErrorHandling;
import org.androidannotations.api.rest.RestClientHeaders;
import org.androidannotations.api.rest.RestClientRootUrl;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.json.GsonHttpMessageConverter;


/**
 * Created by smalant on 14/12/28.
 */
@Rest(converters = GsonHttpMessageConverter.class,
        interceptors = CommonLogInterceptor.class,
        requestFactory = HttpComponentsClientHttpRequestFactory.class)
public interface HaierRestClientCommon extends RestClientRootUrl, RestClientHeaders, RestClientErrorHandling {


    /**
     * 登陆接口
     *
     * @param requestBean
     * @return
     */
    @Post("http://103.8.220.166:40000/security/userlogin")
    @RequiresHeader({"appId", "appKey", "appVersion", "clientId", "accessToken", "Content-Type", "Content-Encoding"})
    @Accept(MediaType.APPLICATION_JSON)
    ResponseEntity<LoginResultBean> login(LoginRequestBean requestBean);


    /**
     * 设备绑定接口
     *
     * @param requestBean
     * @param userId
     * @return
     */
    @Post("http://103.8.220.166:40000/commonapp/users/{userId}/devices")
    @RequiresHeader({"appId", "appKey", "appVersion", "clientId", "accessToken", "Content-Type", "Content-Encoding"})
    @Accept(MediaType.APPLICATION_JSON)
    ResponseEntity<BindDeviceResultBean> bindDevice(BindDeviceRequestBean requestBean, String userId);


    /**
     * 下载用户设备列表
     *
     * @param type           非必填，设备大类
     * @param subType        非必填，设备中类
     * @param specialCode    非必填，设备专用号
     * @param typeIdentifier 非必填，设备类型唯一识别码
     * @param userId         必填
     * @return
     */
    //
    @Get("http://103.8.220.166:40000/commonapp/users/{userId}/devices?sequenceId={sequenceId}&type={type}&subType={subType}&specialCode={specialCode}&typeIdentifier={typeIdentifier}")
    @RequiresHeader({"appId", "appKey", "appVersion", "clientId", "accessToken", "Content-Type", "Content-Encoding"})
    @Accept(MediaType.APPLICATION_JSON)
    ResponseEntity<GetUserDeviceListResultBean> getUserDevices(String sequenceId, String type, String subType, String specialCode, String typeIdentifier, String userId);


    /**
     * 获取用户接入网关接口
     *
     * @param requestBean
     * @return
     */
    @Post("http://103.8.220.166:40000/pms/aas/MB-STARAC-0000/assignAdapter")
    @RequiresHeader({"appId", "appKey", "appVersion", "clientId", "accessToken", "Content-Type", "Content-Encoding"})
    @Accept(MediaType.APPLICATION_JSON)
    ResponseEntity<HaierDeviceGateWayResultBean> getHaierDeviceGateway(HaierDeviceGateWayRequestBean requestBean);


    /**
     * 解绑设备
     *
     * @param userId
     * @param deviceId
     * @param sequenceId
     * @return
     */
    @Delete("http://103.8.220.166:40000/commonapp/users/{userId}/devices/{deviceId}?sequenceId={sequenceId}&userIds={userId}")
    @RequiresHeader({"appId", "appKey", "appVersion", "clientId", "accessToken", "Content-Type", "Content-Encoding"})
    @Accept(MediaType.APPLICATION_JSON)
    ResponseEntity<UnbindResultBean> unbindDevice(String userId, String deviceId, String sequenceId);


    void setHeader(String name, String value);

    String getHeader(String name);


}
